package mission

import (
	"clientDemo/service/cond"
	"clientDemo/service/modulemgr"
	"fmt"
	"github.com/ian-kent/go-log/log"
)

var _m *MissionModule

type MissionModule struct {
	condModule cond.ICondModule
}

func NewMissionModule() *MissionModule {
	tmp := &MissionModule{}
	return tmp
}
func (m *MissionModule) Init(mm modulemgr.IModuleManager) (bool, error) {
	_m = m
	var ok bool
	m.condModule, ok = mm.GetModule(cond.Name).(cond.ICondModule)
	if !ok {
		return false, fmt.Errorf("failed to assert module to ICondModule")
	}
	m.condModule.RegeditBindCond(Name, "1000:30", m.checkMission30)
	m.condModule.RegeditBindCond(Name, "1000:2", m.checkMission2)
	return true, nil
}

func (m *MissionModule) Run(mm modulemgr.IModuleManager) (bool, error) {
	/*	m.condModule.DispatchDataSource(1,
		cond.Value_Category_Growth,
		[]interface{}{uint32(cond.Cond_ValueParamType_Growth_Level), uint32(2)},
		2)*/
	return false, nil
}

func (m *MissionModule) checkMission30(roleId uint32, conf *cond.ConditionConfig, score int64) {
	log.Info("mission checkMission %v_%v_%v", roleId, conf, score)
}
func (m *MissionModule) checkMission2(roleId uint32, conf *cond.ConditionConfig, score int64) {
	log.Info("mission checkMission %v_%v_%v", roleId, conf, score)
}
